package com.kedll.library.adapter;

import io.reactivex.FlowableTransformer;
import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;


public class RxUtil {

    private final static ObservableTransformer schedulersTransformerIO = observable -> observable.subscribeOn(Schedulers.io())
            .unsubscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());

    private final static ObservableTransformer schedulersTransformerComputation = observable -> observable.subscribeOn(Schedulers.computation()).unsubscribeOn(Schedulers.computation()).observeOn(AndroidSchedulers.mainThread());



    /**
     * 统一线程处理
     *
     * @return
     */
    private static FlowableTransformer rxSchedulerHelper = observable -> observable.subscribeOn(Schedulers.io())
            .unsubscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());

    public static FlowableTransformer getRxSchedulerHelper() {
        return rxSchedulerHelper;
    }


    public static ObservableTransformer applySchedulersIO() {
        return schedulersTransformerIO;
    }

    public static ObservableTransformer applySchedulersComputation() {
        return schedulersTransformerComputation;
    }



}